#pragma once
#include "Global.h"
#include "VectorOperations.h"
#include "Quaternion.h"
#include <fstream>
#include <string>
#include <vector>

struct Material{
    std::string name;
    float alpha, ns, ni;
    float dif[3], amb[3], spec[3], tran[3];
    int illum;
    GLuint texture;

    Material(const char* na, float _al, float _ns, float _ni,
    float * _di, float * _am, float *_sp, float * _tf, int ill, GLuint tex);
};

struct textCoord{
    // Tf
    // UV map
    float u, v;
    textCoord(float a, float b);
};

struct FaceVal{

    int vertexIndex[256],textureIndex[256],normalIndex[256];
    int edges, mat;
    FaceVal(int index, int vert, int tex, int norm){
        vertexIndex[index] = (vert);
        textureIndex[index] = (tex);
        normalIndex[index] = (norm);
    };
    FaceVal(){
        edges = 1;
    };
};
class Objects{
public:
    Objects(void);
    Objects(std::string filename, float x, float y, float z);
    Objects(std::string filename, Vector3f &pos, float _scale);
    Objects(std::string filename, Vector3f &pos);
    Objects(std::string filename);
    ~Objects(void);

    void draw();
    void drawVertices();
    void loadObject(const std::string filename);
    void loadMaterial(const std::string filename);
    GLuint loadTexture(const char filename[]);
    void smooth();
    void update();

    Vector3f findCenter();

    bool isSmoothed;

    std::vector<Vector3f> vertices, normals, smoothNormals;
    std::vector<textCoord> textureVs;
    std::vector<FaceVal> faces;
    std::vector<Material> materials;

    // Position and Rotation
    
    Vector3f lastPos, position, direction, velocity, accel, up, right, center;

    // Centered, Scaled, and Rotated vertex (temporary)
    Quaternion * CSR_vertex;
    float scale, xRot, yRot;

private:
    std::string name;
};
